﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Web;
using System.Web.Mvc;
using System.Collections;

namespace PaperSystem.Models
{
    //试卷查询信息
    public class PaperQuery
    {
        public string creator { get; set; }
        public string course { get; set; }
        public string paperTitle { get; set; }
        public string TorE { get; set; }
    }

    //试卷基本信息
    public class PaperList
    {
        public int pid { get; set; }
        public string creator { get; set; }
        [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}")]
        public DateTime? createTime { get; set; }
        public string course { get; set; }
        public int? usedMinute { get; set; }
        public string paperTitle { get; set; }
        public string TorE { get; set; }
    }

    //新增试卷的索引（外表）信息
    public class NewPaper
    {
        public string creatorId { get; set; }
        [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}")]
        public DateTime? createTime { get; set; }
        public string course { get; set; }
        public int? usedMinute { get; set; }
        public string paperTitle { get; set; }
        public string TorE { get; set; }
    }

    //新增试卷的内容（小题）
    public class PaperObject
    {
        public int POorder { get; set; }
        public int Iid { get; set; }
        public float point { get; set; }
    }

    //新增试卷提示信息
    public class PaperInfo
    {
        public int PIorder { get; set; }
        public string before { get; set; }
        public string PIcontent { get; set; }
    }

    //修改试卷（显示）
    public class UpdatePaper
    {
        public int pid { get; set; }
        public string creatorId { get; set; }
        [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}")]
        public DateTime? createTime { get; set; }
        public string course { get; set; }
        public int? usedMinute { get; set; }
        public string paperTitle { get; set; }
        public string TorE { get; set; }
        public UpdatePaperObject[] paperObject { get; set; }
        public UpdatePaperInfo[] paperInfo { get; set; }
    }

    public class UpdatePaperObject
    {
        public int POorder { get; set; }
        public int Iid { get; set; }
        public double? point { get; set; }
        //填充题目外表的内容
        public int eid { get; set; }
        public string content { get; set; }
        public string type { get; set; }
        //填充题目内表的内容
        public int? Iorder { get; set; }
        public string answerMode { get; set; }
        public string Icontent { get; set; }
        public string answer { get; set; }
        //选择题特有
        public string option1 { get; set; }
        public string option2 { get; set; }
        public string option3 { get; set; }
        public string option4 { get; set; }
        public string option5 { get; set; }
        public string option6 { get; set; }
        public string option7 { get; set; }
        public string option8 { get; set; }
        public int? isSingle { get; set; }
        public int? optionNum { get; set; }
        //小题是否新增、删除标记
        public bool isNew { get; set; }
        public bool isDelete { get; set; }
    }

    public class UpdatePaperInfo
    {
        public int PIorder { get; set; }
        public string before { get; set; }
        public string PIcontent { get; set; }
        //小题是否新增、删除标记
        public bool isNew { get; set; }
        public bool isDelete { get; set; }
    }

    //修改试卷（提交）
    public class UpdatePaperPost
    {
        public int pid { get; set; }
        public string creatorId { get; set; }
        [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}")]
        public DateTime? createTime { get; set; }
        public string course { get; set; }
        public int? usedMinute { get; set; }
        public string paperTitle { get; set; }
        public string TorE { get; set; }
    }

    public class UpdatePaperObjectPost
    {
        public int POorder { get; set; }
        public int Iid { get; set; }
        public double? point { get; set; }
        //小题是否新增、删除标记
        public bool isNew { get; set; }
        public bool isDelete { get; set; }
    }

    //做试卷（显示）
    public class PaperUsed
    {
        public int pid { get; set; }
        public string course { get; set; }
        public int? usedMinute { get; set; }
        public string paperTitle { get; set; }
        public string TorE { get; set; }
        [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}")]
        public DateTime? beginTime { get; set; }
        public PaperObjectUsed[] paperObjectUsed { get; set; }
        public PaperInfoUsed[] paperInfoUsed { get; set; }
    }

    public class PaperObjectUsed
    {
        public int POorder { get; set; }
        public int Iid { get; set; }
        public double? point { get; set; }
        //填充题目外表的内容
        public int eid { get; set; }
        public string content { get; set; }
        public string type { get; set; }
        //填充题目内表的内容
        public int? Iorder { get; set; }
        public string answerMode { get; set; }
        public string Icontent { get; set; }
        //选择题特有
        public string option1 { get; set; }
        public string option2 { get; set; }
        public string option3 { get; set; }
        public string option4 { get; set; }
        public string option5 { get; set; }
        public string option6 { get; set; }
        public string option7 { get; set; }
        public string option8 { get; set; }
        public int? isSingle { get; set; }
        public int? optionNum { get; set; }
    }

    public class PaperInfoUsed
    {
        public int PIorder { get; set; }
        public string before { get; set; }
        public string PIcontent { get; set; }
    }

    //做试卷（提交）、改试卷（提交）
    public class ExPaperAnswer
    {
        public string userId { get; set; }
        public int pid { get; set; }
        public string TorE { get; set; }
        [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}")]
        public DateTime beginTime { get; set; }
        public PaperAnswer[] paperAnswer { get; set; }
    }

    public class PaperAnswer
    {
        public int POorder { get; set; }
        public string answer { get; set; }
        public double? score { get; set; }
    }

    //练习答案对比
    public class AnswerQuery
    {
        public string userId { get; set; }
        public int pid { get; set; }
        [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}")]
        public DateTime beginTime { get; set; }
    }

    //练习和考试试卷的信息、所填答案和参考答案
    public class AnswerCompare
    {
        public string userId { get; set; }
        public int pid { get; set; }
        public string TorE { get; set; }
        [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}")]
        public DateTime beginTime { get; set; }
        public string paperTitle { get; set; }

        public AnswerPaperObject[] epaperObject { get; set; }
        public PaperInfoUsed[] epaperInfo { get; set; }
        public double? objectQuestionScore { get; set; }//客观题得分
        public double? paperTotalPoint { get; set; }//试卷满分分数
    }

    public class AnswerPaperObject
    {
        public int POorder { get; set; }
        public int Iid { get; set; }
        public double? point { get; set; }
        //填充题目外表的内容
        public int eid { get; set; }
        public string content { get; set; }
        public string type { get; set; }
        //填充题目内表的内容
        public int? Iorder { get; set; }
        public string answerMode { get; set; }
        public string Icontent { get; set; }
        public string answer { get; set; }
        //选择题特有
        public string option1 { get; set; }
        public string option2 { get; set; }
        public string option3 { get; set; }
        public string option4 { get; set; }
        public string option5 { get; set; }
        public string option6 { get; set; }
        public string option7 { get; set; }
        public string option8 { get; set; }
        public int? isSingle { get; set; }
        public int? optionNum { get; set; }
        //练习答案和得分
        public string userAnswer { get; set; }
        public double? score { get; set; }
        //小题是否答对
        public string isRight { get; set; }//三种情况：right、wrong、uncertain
    }

    //显示使用过该试卷的用户信息
    public class ExamUserInfo
    {
        public int pid { get; set; }
        public string userId { get; set; }
        public string sName { get; set; }
        public DateTime? beginTime { get; set; }
        public string isCorrected { get; set; }//标记该用户的试卷是否已经被批改过（已批改和未批改）
        public double? score { get; set; }
    }

    //继承compare借口，方便distinct
    public class ExamUserInfoComparer : IEqualityComparer<ExamUserInfo>
    {
        bool IEqualityComparer<ExamUserInfo>.Equals(ExamUserInfo x, ExamUserInfo y)
        {
            return x.pid == y.pid && x.sName.Equals(y.sName) && x.beginTime.Equals(y.beginTime);
        }

        int IEqualityComparer<ExamUserInfo>.GetHashCode(ExamUserInfo obj)
        {
            if (obj == null)
            {
                return 0;
            }
            else
            {
                return obj.ToString().GetHashCode();
            }
        }
    }
}
